import time

from Base.Base import Base
from selenium.webdriver.common.by import By
class Page02(Base):
    # 调用点击
    def Click(self) :
        self.dianji_click(self.login_loc)

    user_loc = (By.NAME, 'username')

    # 点击用户名
    def Username(self) :
        self.send_keys(self.user_loc, 'liu121212')

    password_loc = (By.NAME, 'password')

    # 点击密码
    def Password(self) :
        self.send_keys(self.password_loc, '121212')

    # 点击登录
    denglu_loc = (By.XPATH, '//*[@id="theForm"]/div[5]/a')

    def Denglu(self) :
        self.dianji_click(self.denglu_loc)

    #点击首页
    home_loc=(By.LINK_TEXT,'首页')
    def home(self):
        self.dianji_click(self.home_loc)
    #点击输入框
    search_loc=(By.XPATH,'/html/body/div[2]/div/div/form/div[1]/input')
    def kuang(self):
        self.send_keys(self.search_loc,'宋牌电水壶')
        #回车
        self.ENTER(self.search_loc)

    song_loc=(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')
    def song(self):
        self.dianji_click(self.song_loc)

    #清除数量加上填写数量
    nums_loc=(By.CLASS_NAME,'input-regula')
    def nums(self):
        self.clear(self.nums_loc)
        self.send_keys(self.nums_loc,'5')

    #立即购买
    buy_loc=(By.ID,'buy-cart')
    def buy(self):
        self.dianji_click(self.buy_loc)

    # 点击登录，定位
    login_loc = (By.LINK_TEXT, '登录')

    #点击单选框
    danxuan_loc=(By.XPATH,'//*[@id="store-1"]')
    def danxuan(self):
        self.dianji_click(self.danxuan_loc)

    #点击下一步
    xiayibu_loc=(By.LINK_TEXT,'下一步')
    def xiayibu(self):
        self.dianji_click(self.xiayibu_loc)

    # 断言1显示登录成功
    dy1_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')
    yue_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]/span')

    def dy1(self) :
        huanyin = self.text_wenben(self.dy1_loc)
        print(huanyin)
        # yue = self.text_wenben(self.yue_loc)
        # print(yue)

    def A3mall_search_02(self):
        self.open_url('http://10.59.9.12:7001/')
        self.Click()
        self.Username()
        self.Password()
        # 输入验证码时间
        time.sleep(6)
        self.Denglu()
        self.home()
        self.kuang()
        time.sleep(2)
        self.song()
        time.sleep(2)
        self.nums()
        time.sleep(2)
        self.buy()
        self.danxuan()
        time.sleep(2)
        self.xiayibu()
        self.dy1()
        time.sleep(2)


